package com.thread.task;

import com.thread.Flag;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.util.concurrent.CountDownLatch;

/**
 * @Auther: zwg
 * @Date: 2019/2/15 11:03
 * @Description:
 */
@Component
public class MyTask {

    @Async(value = "threadPoolA")
    public void method1(CountDownLatch countDownLatch) throws Exception{
        System.out.println("这是method1，我这里睡5秒"+"我的线程名字："+Thread.currentThread().getName());
        Thread.sleep(5000);
        countDownLatch.countDown();
    }
    @Async(value = "threadPoolA")
    public void method2(CountDownLatch countDownLatch) throws Exception{
        System.out.println("这是method2，我这里睡5秒"+"我的线程名字："+Thread.currentThread().getName());
        Thread.sleep(5000);
        countDownLatch.countDown();
    }
    @Async(value = "threadPoolB")
    public void method3(CountDownLatch countDownLatch) throws Exception{
        System.out.println("这是method3，我这里睡5秒"+"我的线程名字："+Thread.currentThread().getName());
        Thread.sleep(5000);
        countDownLatch.countDown();
    }
    @Async(value = "threadPoolB")
    public void method4(CountDownLatch countDownLatch) throws Exception{
        System.out.println("这是method4，我这里睡5秒"+"我的线程名字："+Thread.currentThread().getName());
        Thread.sleep(5000);
        countDownLatch.countDown();
    }
}
